<template>
  <div class="goodsList">
    <div class="content">
      <div class="item" v-for="(item, index) in curGoodsList" :key="`goods${index}`" @tap="$goGoodsDeail({ id: item.goodsId || item.id })">
        <div class="top">
          <img :src="item.coverUrl" alt="" class="img" mode="aspectFit">
        </div>
        <div class="bottom flex-col">
          <span class="title ellipsis_1">{{item.goodsName || item.name}}</span>
          <scroll-view class="tips scroll-content" :scroll-x="true">
            <span class="tips-item" v-for="(tag, idx) in item.tags" :key="`tag${idx}`">{{tag}}</span>
          </scroll-view>
          <div class="info items-baseline">
            <div class="price items-baseline">
              ￥<span class="big-price">{{item.minimumRentPrice}}</span>/天
            </div>
            <div class="date">
              {{item.minimumRentDay}}天起租
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="finish" v-if="goodsData.finish">
      <p>—— 已经到底啦 ——</p>
    </div>
    <div class="finish loading" v-if="goodsData.loading">
      <p>加载中...</p>
    </div>
  </div>
</template>
<script>
  export default {
    name: 'GoodsList',
    props: {
      data: {
        type: Array,
        default: () => []
      },
      goodsData: {
        type: Object,
        default: () => {
          return {
            finish: false,
            loading: false
          }
        }
      }
    },
    computed: {
      curGoodsList() {
        return this.data.map(item => {
          let tags = []
          if (item.labelsString) {
            tags = item.labelsString.includes(';') ? item.labelsString.split(';') : [item.labelsString]
          } else if (item.tip) {
            tags = item.tip.includes(' ') ? item.tip.split(' ') : [item.tip]
          }
          return {
            ...item,
            tags,
            // ...this.$utils.changePrice(item.minimumRentPrice)
          }
        })
      }
    },
    data() {
      return {

      }
    },
    methods: {
    }
  }
</script>
<style lang="scss">
  .goodsList {
    width: 100%;
    margin-top: 8px;
    >.content {
      display: flex;
      width: 100%;
      padding: 10px 11px 0;
      flex-wrap: wrap;
      .item {
        max-width: 172px;
        height: 232px;
        background: #FFFFFF;
        opacity: 1;
        border-radius: 6px;
        margin-right: 8px;
        margin-bottom: 8px;
        display: flex;
        flex-direction: column;
        &:nth-child(even) {
          margin-right: 0;
        }
        .top {
          width: 172px;
          height: 120px;
          .img {
            width: 100%;
            max-width: 160px;
            height: 120px;
          }
        }
        .bottom {
          margin-top: 10px;
          padding: 10px;
          .title {
            font-size: 14px;
            font-weight: 600;
            // line-height: 16px;
            color: #000;
          }
          .tips {
            display: flex;
            margin-top: 9px;
            .tips-item {
              border: 1px solid #FFB100;
              border-radius: 2px;
              padding: 0 10px;
              height: 18px;
              line-height: 18px;
              font-size: 10px;
              color: #FFB100;
              margin-right: 8px;
              display: inline-block;
              &:last-child {
                margin-right: 0;
              }
            }
          }
          .info {
            display: flex;
            margin-top: 8px;
            width: 100%;
            .price {
              font-size: 16px;
              font-weight: 600;
              line-height: 22px;
              color: #FF5846;
            }
            .date {
              line-height: 14px;
              color: #AAAAAA;
              margin-left: auto;
              font-size: 14px;
            }
          }
        }
      }
    }
    >.finish {
      margin-top: 5px;
      font-size: 14px;
      color: #37A9FF;
      text-align: center;
    }
    >.loading {
      color: #d3d3d3;
    }
  }
</style>
